<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('小程序用户收货地址列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label style="width: 100px">收货人姓名：</label>
                            <input type="text" name="receiverName"/>
                        </li>
                        <li>
                            <label style="width: 100px">收货人电话：</label>
                            <input type="text" name="receiverPhone"/>
                        </li>
                        <li>
                            <label style="width: 100px">详细地址：</label>
                            <input type="text" name="addressLine"/>
                        </li>
                        <li>
                            <label>是否默认：</label>
                            <select name="isDefault" th:with="type=${@dict.getType('applet_default')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 100px">省：</label>
                            <input type="text" name="province"/>
                        </li>
                        <li>
                            <label style="width: 100px">市：</label>
                            <input type="text" name="city"/>
                        </li>
                        <li>
                            <label style="width: 100px">区：</label>
                            <input type="text" name="area"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="applet:appletReceivingAddress:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="applet:appletReceivingAddress:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

    let editFlag = [[${@permission.hasPermi('applet:appletReceivingAddress:edit')}]];
    let removeFlag = [[${@permission.hasPermi('applet:appletReceivingAddress:remove')}]];
    let isDefaultDatas = [[${@dict.getType('applet_default')}]];
    let delFlagDatas = [[${@dict.getType('applet_del_flag')}]];
    let prefix = ctx + "applet/appletReceivingAddress";

    $(function () {
        let options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "小程序用户收货地址",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '收货地址id',
                    visible: false
                },
                {
                    field: 'wxUserId',
                    title: '用户id'
                },
                {
                    field: 'receiverName',
                    title: '收货人姓名'
                },
                {
                    field: 'receiverPhone',
                    title: '收货人电话'
                },
                {
                    field: 'province',
                    title: '省'
                },
                {
                    field: 'city',
                    title: '市'
                },
                {
                    field: 'area',
                    title: '区'
                },
                {
                    field: 'addressLine',
                    title: '详细地址'
                },
                {
                    field: 'postalCode',
                    title: '邮政编码'
                },
                {
                    field: 'isDefault',
                    title: '是否默认',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isDefaultDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        let actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>